﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using Htss.Platform.Web;
namespace DreamBox.Web.Box
{
    public class ajaxforpostsBox:ControllerBox
    {
        public object Load()
        {
            object result = "";
            switch (Request.Form["t"])
            {
                case "UpdatePlusForReply":
                    result = UpdatePlusForReply();
                    break;
                case "PostsAttentionAdd":
                    result = PostsAttentionAdd();
                    break;
                case "UpdatePlusForPosts":
                    result = UpdatePlusForPosts();
                    break;
            }
            return result;
        }

        /// <summary>
        /// 更新回帖Plus
        /// </summary>
        /// <returns></returns>
        public int UpdatePlusForReply()
        {
            int result = 0;
            if (Request.Form["ReplyID"] != null)
            {
                DAL.Posts.Reply posts = new DAL.Posts.Reply();
                if (posts.UpdatePlus(int.Parse(Request.Form["ReplyID"])))
                {
                    result = 1;
                }
                else
                {
                    result = 0;
                }
            }
            return result;
        }
        /// <summary>
        /// 更新收藏记录
        /// </summary>
        /// <returns></returns>
        public string PostsAttentionAdd()
        {
           
            string result = "";
            if (Request.Form["PostsID"] != null)
            {
                DreamBox.DAL.Posts.Attention att = new DAL.Posts.Attention();
                result = att.Add(int.Parse(Request.Form["PostsID"]), int.Parse(Session["UserID"].ToString()));
            }
            return result;
          
        }
        /// <summary>
        /// 更新Plus次数(返回参数:0为失败,1为成功,小于0为没有权限)
        /// </summary>
        /// <returns></returns>
        public int UpdatePlusForPosts()
        {
            int result = 0;

            if (Request.Form["PostsID"] != null && Request.Form["PostsID"] != "")
            {
                DAL.Posts.Posts posts = new DAL.Posts.Posts();
                result = posts.UpdatePlus(int.Parse(Request.Form["PostsID"])) == true ? 1 : 0;
            }
           
            return result;
        }
    }
}
